<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:kml='http://earth.google.com/kml/2.1'>

	<xsl:output method="html" indent="yes" />

	<xsl:template match="/*">
		<div id="div_savedDocumentPanel">
			<xsl:apply-templates />
		</div>
	</xsl:template>

	<xsl:template match="kml:Document">
		<!-- <h1><xsl:apply-templates select="kml:name" /></h1> -->
		<xsl:apply-templates select="kml:Folder" />
	</xsl:template>

	<xsl:template match="kml:Folder">
		<div id="{@id}" class="folder ">
			<div class="documentPanelItem">
				<span class="documentPanelItemCheck"><img src="../img/screenshot/clear.png" alt=""/></span>		
				<img src='../img/screenshot/tinyTwoPage.png'/>
				<xsl:apply-templates select="kml:name" />
			</div>
			<xsl:apply-templates select="kml:Folder" />
			<xsl:apply-templates select="kml:Placemark" />
		</div>
	</xsl:template>

	<xsl:template match="kml:Document/kml:Folder">
		<div containerId='{@id}' dojoType="TitlePane" label="{./kml:name}"
			labelNodeClass="savedDocumentGroupLabel" containerNodeClass="group"
			width="100%" open="true">
			<div class="documentPanelItem">
				<span class="documentPanelItemCheck"><img src='../img/screenshot/clear.png'/></span>
				<img src='../img/screenshot/tinyFolder.png'/> 
				Select all categories in this group
			</div>
			<xsl:apply-templates select="kml:Folder" />
			<xsl:apply-templates select="kml:Placemark" />
		</div>
	</xsl:template>

	<xsl:template match="kml:name">
		<span class="name">
			<xsl:value-of select="." />
		</span>
	</xsl:template>
	<xsl:template match="kml:description">
		<span class="description">
			<xsl:value-of select="." />
		</span>
	</xsl:template>

	<xsl:template match="kml:Placemark">
		<xsl:choose>
			<xsl:when test="kml:Point">
				<div id="{@id}" class="point">
					<div class="documentPanelItem">
						<span class="documentPanelItemCheck"><span class="documentPanelItemCheck"><img src='../img/screenshot/clear.png'/></span></span>
						<img src='../img/screenshot/tinyPageWorld.png'/>
						<xsl:apply-templates select="kml:name" />
						<xsl:apply-templates select="kml:description" />
						<span class="coordinates point"><xsl:value-of select="kml:Point/kml:coordinates" /></span>
						
					</div>
				</div>
			</xsl:when>
			<xsl:when test="kml:LineString">
				<div id="{@id}" class="polyline">
					<div class="documentPanelItem">
						<span class="documentPanelItemCheck"><img src='../img/screenshot/clear.png'/></span>
						<img src='../img/screenshot/tinyMap.png'/>
						<xsl:apply-templates select="kml:name" />
						<xsl:apply-templates select="kml:description" />
						<span class="coordinates polyline">
							<xsl:value-of select="kml:LineString/kml:coordinates"/>
						</span>
					</div>
				</div>
			</xsl:when>
			<xsl:when test="kml:Polygon">
				<div id="{@id}" class="polygon">
					<div class="documentPanelItem">
						<span class="documentPanelItemCheck"><img src='../img/screenshot/clear.png'/></span>
						<img src='../img/screenshot/tinyPage.png'/>
						<xsl:apply-templates select="kml:name" />
						<xsl:apply-templates select="kml:description" />
						<span class="coordinates polygon">
							<xsl:value-of select="kml:Polygon/kml:outerBoundaryIs/kml:LinearRing/kml:coordinates"/>
						</span>
					</div>
				</div>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	<xsl:template
		match=" kml:open | kml:linestring | kml:Style | kml:StyleMap | kml:Point | kml:linearring " />

</xsl:stylesheet>

